package com.blb.utils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class IconfontUtils {

    /**
     * 获取图标的class集合
     *
     * @param request
     * @return
     * @throws IOException
     */
    public static List<String> getIconfonts(HttpServletRequest request) throws IOException {
        List<String> icons = new ArrayList<String>();
        Document document = Jsoup.parse(new File(PathUtils.getIconFile(request)), "utf-8");
        Elements elements = document.getElementsByClass("font-class");
        Elements elements2 = elements.get(0).getElementsByClass("code-name");
        for (Element element : elements2) {
            icons.add(element.text().replace(".", ""));
        }
        return icons;
    }
}
